<template>
    <!-- index.wxml -->
    <view class="container">
        <view class="page-section">
        	<search-bar></search-bar>
        </view>

        <view>
            <swiper class="swiper" autoplay indicator-dots indicator-active-color="#ffff">
                <swiper-item>
                    <image
                        src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp4.itc.cn%2Fq_70%2Fimages03%2F20210711%2F2d58ef199d614ef6833161670c45c5e0.jpeg&refer=http%3A%2F%2Fp4.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651919216&t=1897c2eb855fa050b3b626b63a78c07e"
                    ></image>
                </swiper-item>

                <swiper-item>
                    <image
                        src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp4.itc.cn%2Fq_70%2Fimages03%2F20210711%2F2d58ef199d614ef6833161670c45c5e0.jpeg&refer=http%3A%2F%2Fp4.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651919216&t=1897c2eb855fa050b3b626b63a78c07e"
                    ></image>
                </swiper-item>
				
                <swiper-item>
                    <image
                        src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp4.itc.cn%2Fq_70%2Fimages03%2F20210711%2F2d58ef199d614ef6833161670c45c5e0.jpeg&refer=http%3A%2F%2Fp4.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651919216&t=1897c2eb855fa050b3b626b63a78c07e"
                    ></image>
                </swiper-item>
            </swiper>
        </view>

        <view class="six_button">
            <view style="padding: 20rpx"></view>
            <view class="buttons">
                <view class="aicon">
                    <view>
                        <button class="cornerbutton" style="width: 120rpx; height: 120rpx; background-color: #f4fffa" @tap="goFoodRecord">
                            <uni-icons custom-prefix="iconfont" type="icon-food" size="30"></uni-icons>
                        </button>
                    </view>
                    <view class="ziti">饮食打卡</view>
                </view>
                <text style="padding: 30rpx"></text>

                <view class="aicon">
                    <view>
                        <button class="cornerbutton" style="width: 120rpx; height: 120rpx; background-color: #f7f8ff" @tap="goRunRecord">
                            <uni-icons custom-prefix="iconfont" type="icon-yundong" size="30"></uni-icons>
                        </button>
                    </view>
                    <view class="ziti">跑步打卡</view>
                </view>

                <text style="padding: 30rpx"></text>

                <view class="aicon">
                    <view>
                        <button class="cornerbutton" style="width: 120rpx; height: 120rpx; background-color: #fffef7" @tap="goSleepRecord">
                            <uni-icons custom-prefix="iconfont" type="icon-sleep" size="30"></uni-icons>
                        </button>
                    </view>
                    <view class="ziti">睡眠记录</view>
                </view>
            </view>

            <text style="padding: 20rpx"></text>

            <view class="buttons">
                <view class="aicon">
                    <view>
                        <button class="cornerbutton" style="width: 120rpx; height: 120rpx; background-color: #fff9f9" @tap="goMyMessage">
                            <uni-icons type="email" size="30"></uni-icons>
                        </button>
                    </view>
                    <view class="ziti">查看私信</view>
                </view>
                <text style="padding: 30rpx"></text>

                <view class="aicon">
                    <view>
                        <button
                            class="cornerbutton"
                            style="background-color: #fef8ff; width: 120rpx; height: 120rpx; position: relative; left: 2rpx; top: 0rpx"
                            @tap="goStartAssess"
                        >
                            <uni-icons type="compose" size="30"></uni-icons>
                        </button>
                    </view>
                    <view class="ziti">开启评估</view>
                </view>

                <text style="padding: 30rpx"></text>

                <view class="aicon">
                    <view>
                        <button class="cornerbutton" style="background-color: #f6fdff; width: 120rpx; height: 120rpx" @tap="goWaterRecord">
                            <uni-icons custom-prefix="iconfont" type="icon-water-cup" size="30"></uni-icons>
                        </button>
                    </view>
                    <view class="ziti">饮水记录</view>
                </view>
            </view>
        </view>

        <text style="padding: 20rpx"></text>

        <view class="weui-footer">
            <view class="weui-footer__text">Copyright @2022 yyOrangeCompany</view>
        </view>
    </view>
</template>

<script>
// index.js
// 获取应用实例
	import SearchBar from '@/components/SearchBar.vue'
const app = getApp();
export default {
    data() {
        return {
            inputShowed: false,
            inputVal: '',
            indicatorDots: '',
            autoplay: '',
            interval: '',
            duration: '',
            userInfo: '',
            hasUserInfo: false
        };
    },
    onShareAppMessage() {
        return {
            title: 'swiper',
            path: 'pages/index/index'
        };
    },
    onLoad: function () {},
	components:{
		SearchBar
	},
    methods: {
        changeIndicatorDots() {
            this.setData({
                indicatorDots: !this.indicatorDots
            });
        },

        changeAutoplay() {
            this.setData({
                autoplay: !this.autoplay
            });
        },

        intervalChange(e) {
            this.setData({
                interval: e.detail.value
            });
        },

        durationChange(e) {
            this.setData({
                duration: e.detail.value
            });
        },

        getUserProfile(e) {
            // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认，开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
            uni.getUserProfile({
                desc: '展示用户信息',
                // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
                success: (res) => {
                    console.log(res);
                    this.setData({
                        userInfo: res.userInfo,
                        hasUserInfo: true
                    });
                }
            });
        },

        getUserInfo(e) {
            // 不推荐使用getUserInfo获取用户信息，预计自2021年4月13日起，getUserInfo将不再弹出弹窗，并直接返回匿名的用户个人信息
            console.log(e);
            this.setData({
                userInfo: e.detail.userInfo,
                hasUserInfo: true
            });
        },

        goStartAssess: function (e) {
            console.log();

            if (this.hasLogin) {
                uni.navigateTo({
                    url: e.currentTarget.dataset.url
                });
            } else {
                uni.navigateTo({
                    url: '/pages/user/assess/assess'
                });
            }
        },

        goFoodRecord: function (e) {
            console.log();

            if (this.hasLogin) {
                uni.navigateTo({
                    url: e.currentTarget.dataset.url
                });
            } else {
                uni.navigateTo({
                    url: '../health/food/clockIn/clockIn'
                });
            }
        },

        goSleepRecord: function (e) {
            console.log();

            if (this.hasLogin) {
                uni.navigateTo({
                    url: e.currentTarget.dataset.url
                });
            } else {
                uni.navigateTo({
                    url: '/pages/health/'
                });
            }
        },

        goMyMessage: function (e) {
            console.log();

            if (this.hasLogin) {
                uni.navigateTo({
                    url: e.currentTarget.dataset.url
                });
            } else {
                uni.navigateTo({
                    url: '/pages/index/myMessage/myMessage'
                });
            }
        },

        goRunRecord: function (e) {
            console.log();

            if (this.hasLogin) {
                uni.navigateTo({
                    url: e.currentTarget.dataset.url
                });
            } else {
                uni.navigateTo({
                    url: '../health/sports/clockIn/clockIn'
                });
            }
        },

        goWaterRecord: function (e) {
            console.log();

            if (this.hasLogin) {
                uni.navigateTo({
                    url: e.currentTarget.dataset.url
                });
            } else {
                uni.navigateTo({
                    url: '../health/sports/clockIn/clockIn'
                });
            }
        },

        showInput() {
            this.setData({
                inputShowed: true
            });
        },

        hideInput() {
            this.setData({
                inputVal: '',
                inputShowed: false
            });
        },

        clearInput() {
            this.setData({
                inputVal: ''
            });
        },

        inputTyping(e) {
            this.setData({
                inputVal: e.detail.value
            });
        }
    }
};
</script>
<style>
@import './index.css';
</style>
